# def my_abs(x):
#     if x >= 0:
#         return x
#     else:
#         return -x


# #加入参数类型检查
# def my_abs(x):
#     if not isinstance(x,(int,float)):
#         raise TypeError('bad operand type')
#     if x >= 0:
#         return x
#     else:
#         return -x


# import math
# def move(x,y,step,angle = 0):
#     nx = x + step*math.cos(angle)
#     ny = y - step*math.sin(angle)
#     return nx,ny
# r = move(100,100,60,math.pi/6)
# print(r)


# #一元二次方程的根
# import math
# def quadratic(a,b,c):




# import math

# def quadratic(a, b, c):
#     if b**2 -4*a*c < 0:
#         raise ValueError('wrong number')
#     x1 = (-b + (math.sqrt(b**2 -4*a*c)))/(2*a)
#     x2 = (-b - (math.sqrt(b**2 -4*a*c)))/(2*a)
#     return x1,x2

# # 测试:
# print('quadratic(2, 3, 1) =', quadratic(2, 3, 1))
# print('quadratic(1, 3, -4) =', quadratic(1, 3, -4))

# if quadratic(2, 3, 1) != (-0.5, -1.0):
#     print('测试失败')
# elif quadratic(1, 3, -4) != (1.0, -4.0):
#     print('测试失败')
# else:
#     print('测试成功')





# def calc(*numbers):
#     sum = 0
#     for n in numbers:
#         sum = sum + n * n
#     return sum



# def person(name, age, **kw):
#     print('name:', name, 'age:', age, 'other:', kw)



# def f2(a, b, c=0, *, d, **kw):
#     print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw)
# args = (1, 2, 3)
# kw = {'d': 88, 'x': '#'}   #关键字参数‘d’可修改d变量的值
# f2(*args, **kw)



# def mul(*args):
#     #未考虑到args为空的情况
#     if len(args) == 0:
#         raise TypeError('at least 1 argument')
#     sum = 1
#     for n in args:
#         #未考虑判断数据类型
#         if not isinstance(n,(int,float)):
#             raise ValueError('wrong value')
#         sum = sum * n
#     return sum

# # 测试
# print('mul(5) =', mul(5))
# print('mul(5, 6) =', mul(5, 6))
# print('mul(5, 6, 7) =', mul(5, 6, 7))
# print('mul(5, 6, 7, 9) =', mul(5, 6, 7, 9))
# if mul(5) != 5:
#     print('mul(5)测试失败!')
# elif mul(5, 6) != 30:
#     print('mul(5, 6)测试失败!')
# elif mul(5, 6, 7) != 210:
#     print('mul(5, 6, 7)测试失败!')
# elif mul(5, 6, 7, 9) != 1890:
#     print('mul(5, 6, 7, 9)测试失败!')
# else:
#     try:
#         mul()
#         print('mul()测试失败!')
#     except TypeError:
#         print('测试成功!')




#汉诺塔问题
def move(n,a,b,c):
    if n == 1:
        print(a,'-->',c)
    else:
        # move(1,a,c,b)
        # move(1,b,a,c)
        # move(n-1,a,b,c)
        #思考反了，要按原顺序，我给出的解法是倒序的
        #移动一步时是从a到c，即a为原柱，b为过度柱，c为目标柱

        #先将a顶上的n-1个盘子借助c移动到b
        move(n-1,a,c,b)
        #然后将a上最底下的盘子一步移动到c
        move(1,a,b,c)
        #最后再把b上的n-1个盘子借助a移动到c上
        move(n-1,b,a,c)
move(3,'A','B','C')